/*
 * Copyright 2010 The Apache Software Foundation
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.hadoop.hbase.security;

import java.io.IOException;

/**
 * Wrapper to abstract out usage of user and group information in HBase.
 *
 * <p>
 * This class provides a common interface for interacting with user and group
 * information across changing APIs in different versions of Hadoop.  It only
 * provides access to the common set of functionality in
 * {@link org.apache.hadoop.security.UserGroupInformation} currently needed by
 * HBase, but can be extended as needs change.
 * </p>
 */
public abstract class User {
	public static final String DEFAULT_USER_NAME = "DEFAULT_USER_NAME";

	/**
	 * Returns the full user name.  For Kerberos principals this will include
	 * the host and realm portions of the principal name.
	 * @return User full name.
	 */
	public String getName() {
		return DEFAULT_USER_NAME;
	}

	public static class DummyUser extends User {
	}

	/**
	 * Returns the shortened version of the user name -- the portion that maps
	 * to an operating system user name.
	 * @return Short name
	 */
	public String getShortName() {
		return DEFAULT_USER_NAME;
	}

	/**
	 * Returns the {@code User} instance within current execution context.
	 */
	public static User getCurrent() throws IOException {
		return new DummyUser();
	}
}
